<?php
/**
 * Created by PhpStorm.
 * User: DaibiDaddy
 * Date: 2016/6/3
 * Time: 14:59
 */

namespace App\Setting;

use App\Base\BaseForm;
use App\Base\ViewsInList;

class ProjectSetting{

    /*手动获取的配置项*/
    public $catType = "level";//Options:level snake
    public $entityCnName = "资讯";//模块名称
    public $table = "Project";//数据表名称
    public $editKeys = array('id','name','vi','salt','addtime','status');//后台管理列表中可以直接编辑的字段
    public $perPage = 10;//后台管理列表中可以直接编辑的字段

    /*自动获取的配置项*/
    public $bundleName;
    public $entityName;
    public $SettingPath;
    public $entityPath;
    public $entity;
    public $modelPath;
    public $doctrine;
    public $em;

    public function __construct($doctrine)
    {
        $this->bundleName = "App";
        $this->entityName = str_replace("\\","",str_replace("Setting","",str_replace(__NAMESPACE__,"",__CLASS__)));
        $this->SettingPath = __CLASS__;
        //$this->entityPath = str_replace($this->entityName."Entity",$this->entityName,str_replace("Setting","Entity",__CLASS__));
        $this->entityPath = "App\\Entity\\".$this->entityName;
        $this->entity = new $this->entityPath();
        $this->modelPath = str_replace("Setting","Model",__CLASS__);
        $this->doctrine = $doctrine;
        $this->em = $doctrine->getManager();
    }

    public function listConfig()
    {
        $default = array();
        $default["Project AS Project"]["select"] = array('id','name','vi','salt','addtime','status');
        $default["Project AS Project"]["search"] = array('id','name','vi','salt','addtime','status');
        $default["Project AS Project"]["condition"] = array('id','name','vi','salt','addtime','status');
        $default["Project AS Project"]["orderBy"] = array('id'=>"DESC");

        $join = array();
//        $join["ProjectCategory"]["on"] = "";
//        $join["ProjectCategory"]["select"] = array();
//        $join["ProjectCategory"]["search"] = array();
//        $join["ProjectCategory"]["condition"] = array();
//        $join["ProjectCategory"]["orderBy"] = array();

        return array(
            "default"   => $default,
            "joins"     => $join,
        );
    }

    public function viewConfig()
    {

    }


    public function formConfig()
    {
        $BaseForm = new BaseForm();
        
        $config["name"] = $BaseForm->text("name","名称");
        $config["vi"] = $BaseForm->text("vi","vi");
        $config["salt"] = $BaseForm->text("salt","salt");
//        $config["addtime"] = $BaseForm->s("addtime","创建时间");
        $config["status"] = $BaseForm->switch("status","状态",[0,1]);
        return $config;
    }
}